'''
链表节点的插入
    p.next = curnode.next
    curnode.next = p
链表节点的删除
    p = curnode.next
    curnode.next = cuenode.next.next/p.next
    del p
'''
class Node:
    def __init__(self,item):
        self.item = item
        self.next = None

def creat_linklist_tail(li):
    head = Node(li[0])
    tail = head
    for element in li[1:]:
        node = Node(element)
        tail.next = node
        tail = node
    return head

def creat_linklist_head(li):
    head = Node(li[0])
    for element in li[1:]:
        node = Node(element)
        node.next = head
        head = node
    return head

def print_linklist(lk):
    while lk:
        print(lk.item,end=' ')
        lk = lk.next

# lk = creat_linklist_head([1,2,3])
# print(lk.item)
# print(lk.next)
# print(lk.next.item)
lk1 = creat_linklist_tail([1,2,3,4,5,6])
# print_linklist(lk)
print(lk1.item)
print(lk1.next.item)
print_linklist(lk1)